Flutter / Basic / Logger
Logger
-
Steps
The logger package in Flutter is a versatile and straightforward logging package that allows you to print log messages to the console. It provides different log levels and allows you to control the verbosity of your logs.
1. pubspec.yaml
dependencies: logger: ^2.0.0 2. Screen
import 'package:flutter/material.dart'; import 'package:logger/logger.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { // Initialize logger final logger = Logger(); @override Widget build(BuildContext context) { // Example log messages logger.v('Verbose log message'); logger.d('Debug log message'); logger.i('Info log message'); logger.w('Warning log message'); logger.e('Error log message'); logger.wtf('What a terrible failure log message'); return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Logger Example'), ), body: Center( child: Text('Check the console for log messages.'), ), ), ); } }